<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>校园活动管理系统</title>
    <style>
        * {
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', sans-serif;
            margin: 0;
            background-color: #e6f7ff;
        }

        .header {
            background-color: #0050b3;
            color: white;
            text-align: center;
            padding: 20px;
        }

        .nav {
            background-color: #3385ff;
            display: flex;
            justify-content: center;
        }

        .nav button {
            background-color: transparent;
            border: none;
            color: white;
            padding: 15px 20px;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        .nav button:hover {
            background-color: #0050b3;
        }

        .nav button.active {
            background-color: #003a8c;
        }

        .main {
            padding: 20px;
        }

        .tab-content {
            display: none;
            background-color: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }

        th,
        td {
            border: 1px solid #ddd;
            padding: 12px;
            text-align: left;
        }

        th {
            background-color: #f0f6ff;
        }

        button {
            padding: 8px 16px;
            border-radius: 4px;
            border: none;
            cursor: pointer;
            transition: background-color 0.3s;
        }

        .add-btn {
            background-color: #52c41a;
            color: white;
        }

        .add-btn:hover {
            background-color: #389e0d;
        }

        .edit-btn {
            background-color: #faad14;
            color: white;
        }

        .edit-btn:hover {
            background-color: #d48806;
        }

        .delete-btn {
            background-color: #ff4d4f;
            color: white;
        }

        .delete-btn:hover {
            background-color: #cf1322;
        }

        .modal {
            display: none;
            position: fixed;
            z-index: 1;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgba(0, 0, 0, 0.4);
        }

        .modal-content {
            background-color: #fefefe;
            margin: 15% auto;
            padding: 20px;
            border: 1px solid #888;
            width: 30%;
            border-radius: 8px;
        }

        .close {
            color: #aaa;
            float: right;
            font-size: 28px;
            font-weight: bold;
        }

        .close:hover,
        .close:focus {
            color: black;
            text-decoration: none;
            cursor: pointer;
        }

        /* 新增搜索框样式 */
        .search-container {
            margin-bottom: 10px;
        }

        .search-container input[type="text"] {
            padding: 8px;
            border: 1px solid #ddd;
            border-radius: 4px;
        }

        .search-container button {
            padding: 8px 16px;
            border-radius: 4px;
            border: none;
            background-color: #0050b3;
            color: white;
            cursor: pointer;
        }

        .search-container button:hover {
            background-color: #003a8c;
        }
    </style>
</head>

<body>
    <div class="header">
        <h1>校园活动管理系统</h1>
    </div>
    <div class="nav">
        <button class="tablinks" onclick="openTab(event, 'Home')">首页</button>
        <button class="tablinks" onclick="openTab(event, 'ActivityManagement')">活动信息管理</button>
        <button class="tablinks" onclick="openTab(event, 'ParticipantManagement')">参与者信息管理</button>
        <button class="tablinks" onclick="openTab(event, 'RegistrationManagement')">报名信息管理</button>
        <button class="tablinks" onclick="openTab(event, 'EvaluationManagement')">活动评价管理</button>
        <button class="tablinks" onclick="openTab(event, 'Statistics')">数据统计</button>
    </div>
    <div class="main">
        <div id="Home" class="tab-content">
            <h2>首页</h2>
            <p>欢迎使用校园活动管理系统，您可以通过顶部导航栏选择不同的功能模块进行操作。</p>
        </div>
        <div id="ActivityManagement" class="tab-content">
            <h2>活动信息管理</h2>
            <!-- 新增搜索框 -->
            <div class="search-container">
                <input type="text" id="activitySearch" placeholder="搜索活动名称">
                <button onclick="searchActivities()">搜索</button>
            </div>
            <button class="add-btn" onclick="openAddActivityModal()">添加活动</button>
            <table id="activityTable">
                <thead>
                    <tr>
                        <th>活动名称</th>
                        <th>活动时间</th>
                        <th>活动地点</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>
        <div id="ParticipantManagement" class="tab-content">
            <h2>参与者信息管理</h2>
            <!-- 新增搜索框 -->
            <div class="search-container">
                <input type="text" id="participantSearch" placeholder="搜索参与者姓名">
                <button onclick="searchParticipants()">搜索</button>
            </div>
            <button class="add-btn" onclick="openAddParticipantModal()">添加参与者</button>
            <table id="participantTable">
                <thead>
                    <tr>
                        <th>参与者姓名</th>
                        <th>联系方式</th>
                        <th>所在班级</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>
        <div id="RegistrationManagement" class="tab-content">
            <h2>报名信息管理</h2>
            <!-- 新增搜索框 -->
            <div class="search-container">
                <input type="text" id="registrationSearch" placeholder="搜索活动名称或参与者姓名">
                <button onclick="searchRegistrations()">搜索</button>
            </div>
            <button class="add-btn" onclick="openAddRegistrationModal()">添加报名信息</button>
            <table id="registrationTable">
                <thead>
                    <tr>
                        <th>活动名称</th>
                        <th>参与者姓名</th>
                        <th>报名时间</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>
        <div id="EvaluationManagement" class="tab-content">
            <h2>活动评价管理</h2>
            <!-- 新增搜索框 -->
            <div class="search-container">
                <input type="text" id="evaluationSearch" placeholder="搜索活动名称或评价人姓名">
                <button onclick="searchEvaluations()">搜索</button>
            </div>
            <button class="add-btn" onclick="openAddEvaluationModal()">添加评价</button>
            <table id="evaluationTable">
                <thead>
                    <tr>
                        <th>活动名称</th>
                        <th>评价人姓名</th>
                        <th>评价内容</th>
                        <th>评价时间</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>
        <div id="Statistics" class="tab-content">
            <h2>数据统计</h2>
            <p>活动总数: <span id="activityCount">0</span></p>
            <p>参与者总数: <span id="participantCount">0</span></p>
            <p>报名记录总数: <span id="registrationCount">0</span></p>
            <p>评价总数: <span id="evaluationCount">0</span></p>
        </div>
    </div>

    <!-- 添加活动模态框 -->
    <div id="addActivityModal" class="modal">
        <div class="modal-content">
            <span class="close" onclick="closeAddActivityModal()">&times;</span>
            <h3>添加/修改活动</h3>
            <label for="activityName">活动名称:</label>
            <input type="text" id="activityName" placeholder="请输入活动名称">
            <br>
            <label for="activityTime">活动时间:</label>
            <input type="text" id="activityTime" placeholder="请输入活动时间">
            <br>
            <label for="activityLocation">活动地点:</label>
            <input type="text" id="activityLocation" placeholder="请输入活动地点">
            <br>
            <button onclick="saveActivity()">保存</button>
        </div>
    </div>

    <!-- 添加参与者模态框 -->
    <div id="addParticipantModal" class="modal">
        <div class="modal-content">
            <span class="close" onclick="closeAddParticipantModal()">&times;</span>
            <h3>添加/修改参与者</h3>
            <label for="participantName">参与者姓名:</label>
            <input type="text" id="participantName" placeholder="请输入参与者姓名">
            <br>
            <label for="participantContact">联系方式:</label>
            <input type="text" id="participantContact" placeholder="请输入联系方式">
            <br>
            <label for="participantClass">所在班级:</label>
            <input type="text" id="participantClass" placeholder="请输入所在班级">
            <br>
            <button onclick="saveParticipant()">保存</button>
        </div>
    </div>

    <!-- 添加报名信息模态框 -->
    <div id="addRegistrationModal" class="modal">
        <div class="modal-content">
            <span class="close" onclick="closeAddRegistrationModal()">&times;</span>
            <h3>添加/修改报名信息</h3>
            <label for="registrationActivity">活动名称:</label>
            <input type="text" id="registrationActivity" placeholder="请输入活动名称">
            <br>
            <label for="registrationParticipant">参与者姓名:</label>
            <input type="text" id="registrationParticipant" placeholder="请输入参与者姓名">
            <br>
            <label for="registrationTime">报名时间:</label>
            <input type="text" id="registrationTime" placeholder="请输入报名时间">
            <br>
            <button onclick="saveRegistration()">保存</button>
        </div>
    </div>

    <!-- 添加评价模态框 -->
    <div id="addEvaluationModal" class="modal">
        <div class="modal-content">
            <span class="close" onclick="closeAddEvaluationModal()">&times;</span>
            <h3>添加/修改评价</h3>
            <label for="evaluationActivity">活动名称:</label>
            <input type="text" id="evaluationActivity" placeholder="请输入活动名称">
            <br>
            <label for="evaluationPerson">评价人姓名:</label>
            <input type="text" id="evaluationPerson" placeholder="请输入评价人姓名">
            <br>
            <label for="evaluationContent">评价内容:</label>
            <textarea id="evaluationContent" placeholder="请输入评价内容"></textarea>
            <br>
            <button onclick="saveEvaluation()">保存</button>
        </div>
    </div>

    <script>
        // 初始化表格
        function initTables() {
            // 活动管理
            let activities = JSON.parse(localStorage.getItem('activities')) || [];
            if (activities.length === 0) {
                activities = [
                    { name: '校园篮球赛', time: '2025-03-25', location: '学校篮球场' },
                    { name: '文艺晚会', time: '2025-04-01', location: '学校礼堂' },
                    { name: '学术讲座', time: '2025-04-08', location: '图书馆报告厅' },
                    { name: '运动会', time: '2025-04-15', location: '学校操场' },
                    { name: '志愿者活动', time: '2025-04-22', location: '社区服务中心' },
                    { name: '摄影比赛', time: '2025-04-29', location: '学校艺术楼' },
                    { name: '社团招新', time: '2025-05-06', location: '学校广场' },
                    { name: '科技展览', time: '2025-05-13', location: '学校科技馆' },
                    { name: '歌唱比赛', time: '2025-05-20', location: '学校音乐厅' },
                    { name: '户外拓展', time: '2025-05-27', location: '郊外拓展基地' }
                ];
                localStorage.setItem('activities', JSON.stringify(activities));
            }
            let activityTable = document.getElementById('activityTable').getElementsByTagName('tbody')[0];
            activityTable.innerHTML = '';
            activities.forEach((activity, index) => {
                let row = activityTable.insertRow();
                let cell1 = row.insertCell(0);
                let cell2 = row.insertCell(1);
                let cell3 = row.insertCell(2);
                let cell4 = row.insertCell(3);
                cell1.innerHTML = activity.name;
                cell2.innerHTML = activity.time;
                cell3.innerHTML = activity.location;
                cell4.innerHTML = `<button class="edit-btn" onclick="openEditActivityModal(${index})">编辑</button><button class="delete-btn" onclick="deleteActivity(${index})">删除</button>`;
            });

            // 参与者管理
            let participants = JSON.parse(localStorage.getItem('participants')) || [];
            if (participants.length === 0) {
                participants = [
                    { name: '张三', contact: '13800138000', class: '计算机科学与技术专业1班' },
                    { name: '李四', contact: '13900139000', class: '电子信息工程专业2班' },
                    { name: '王五', contact: '13700137000', class: '软件工程专业3班' },
                    { name: '赵六', contact: '13600136000', class: '通信工程专业4班' },
                    { name: '孙七', contact: '13500135000', class: '自动化专业5班' },
                    { name: '周八', contact: '13400134000', class: '机械设计制造及其自动化专业6班' },
                    { name: '吴九', contact: '13300133000', class: '电气工程及其自动化专业7班' },
                    { name: '郑十', contact: '13200132000', class: '土木工程专业8班' },
                    { name: '王十一', contact: '13100131000', class: '会计学专业9班' },
                    { name: '李十二', contact: '13000130000', class: '市场营销专业10班' }
                ];
                localStorage.setItem('participants', JSON.stringify(participants));
            }
            let participantTable = document.getElementById('participantTable').getElementsByTagName('tbody')[0];
            participantTable.innerHTML = '';
            participants.forEach((participant, index) => {
                let row = participantTable.insertRow();
                let cell1 = row.insertCell(0);
                let cell2 = row.insertCell(1);
                let cell3 = row.insertCell(2);
                let cell4 = row.insertCell(3);
                cell1.innerHTML = participant.name;
                cell2.innerHTML = participant.contact;
                cell3.innerHTML = participant.class;
                cell4.innerHTML = `<button class="edit-btn" onclick="openEditParticipantModal(${index})">编辑</button><button class="delete-btn" onclick="deleteParticipant(${index})">删除</button>`;
            });

            // 报名信息管理
            let registrations = JSON.parse(localStorage.getItem('registrations')) || [];
            if (registrations.length === 0) {
                registrations = [
                    { activity: '校园篮球赛', participant: '张三', time: '2025-03-20' },
                    { activity: '文艺晚会', participant: '李四', time: '2025-03-28' },
                    { activity: '学术讲座', participant: '王五', time: '2025-04-03' },
                    { activity: '运动会', participant: '赵六', time: '2025-04-10' },
                    { activity: '志愿者活动', participant: '孙七', time: '2025-04-17' },
                    { activity: '摄影比赛', participant: '周八', time: '2025-04-24' },
                    { activity: '社团招新', participant: '吴九', time: '2025-05-01' },
                    { activity: '科技展览', participant: '郑十', time: '2025-05-08' },
                    { activity: '歌唱比赛', participant: '王十一', time: '2025-05-15' },
                    { activity: '户外拓展', participant: '李十二', time: '2025-05-22' }
                ];
                localStorage.setItem('registrations', JSON.stringify(registrations));
            }
            let registrationTable = document.getElementById('registrationTable').getElementsByTagName('tbody')[0];
            registrationTable.innerHTML = '';
            registrations.forEach((registration, index) => {
                let row = registrationTable.insertRow();
                let cell1 = row.insertCell(0);
                let cell2 = row.insertCell(1);
                let cell3 = row.insertCell(2);
                let cell4 = row.insertCell(3);
                cell1.innerHTML = registration.activity;
                cell2.innerHTML = registration.participant;
                cell3.innerHTML = registration.time;
                cell4.innerHTML = `<button class="edit-btn" onclick="openEditRegistrationModal(${index})">编辑</button><button class="delete-btn" onclick="deleteRegistration(${index})">删除</button>`;
            });

            // 活动评价管理
            let evaluations = JSON.parse(localStorage.getItem('evaluations')) || [];
            if (evaluations.length === 0) {
                evaluations = [
                    { activity: '校园篮球赛', person: '张三', content: '比赛很精彩，希望以后多举办', time: '2025-03-26' },
                    { activity: '文艺晚会', person: '李四', content: '节目很丰富，演员表演很出色', time: '2025-04-02' },
                    { activity: '学术讲座', person: '王五', content: '讲座内容很有深度，收获很大', time: '2025-04-09' },
                    { activity: '运动会', person: '赵六', content: '组织有序，氛围热烈', time: '2025-04-16' },
                    { activity: '志愿者活动', person: '孙七', content: '很有意义的活动，下次还参加', time: '2025-04-23' },
                    { activity: '摄影比赛', person: '周八', content: '作品质量很高，开阔了眼界', time: '2025-04-30' },
                    { activity: '社团招新', person: '吴九', content: '社团种类丰富，找到了自己感兴趣的', time: '2025-05-07' },
                    { activity: '科技展览', person: '郑十', content: '展示了很多前沿科技，很有启发', time: '2025-05-14' },
                    { activity: '歌唱比赛', person: '王十一', content: '选手实力都很强，听得很过瘾', time: '2025-05-21' },
                    { activity: '户外拓展', person: '李十二', content: '挑战自我，增进了团队友谊', time: '2025-05-28' }
                ];
                localStorage.setItem('evaluations', JSON.stringify(evaluations));
            }
            let evaluationTable = document.getElementById('evaluationTable').getElementsByTagName('tbody')[0];
            evaluationTable.innerHTML = '';
            evaluations.forEach((evaluation, index) => {
                let row = evaluationTable.insertRow();
                let cell1 = row.insertCell(0);
                let cell2 = row.insertCell(1);
                let cell3 = row.insertCell(2);
                let cell4 = row.insertCell(3);
                let cell5 = row.insertCell(4);
                cell1.innerHTML = evaluation.activity;
                cell2.innerHTML = evaluation.person;
                cell3.innerHTML = evaluation.content;
                cell4.innerHTML = evaluation.time;
                cell5.innerHTML = `<button class="edit-btn" onclick="openEditEvaluationModal(${index})">编辑</button><button class="delete-btn" onclick="deleteEvaluation(${index})">删除</button>`;
            });

            // 更新数据统计
            document.getElementById('activityCount').textContent = activities.length;
            document.getElementById('participantCount').textContent = participants.length;
            document.getElementById('registrationCount').textContent = registrations.length;
            document.getElementById('evaluationCount').textContent = evaluations.length;
        }

        // 打开 tab 页面
        function openTab(evt, tabName) {
            let i, tabcontent, tablinks;
            tabcontent = document.getElementsByClassName('tab-content');
            for (i = 0; i < tabcontent.length; i++) {
                tabcontent[i].style.display = 'none';
            }
            tablinks = document.getElementsByClassName('tablinks');
            for (i = 0; i < tablinks.length; i++) {
                tablinks[i].className = tablinks[i].className.replace(' active', '');
            }
            document.getElementById(tabName).style.display = 'block';
            evt.currentTarget.className += ' active';
        }

        // 活动管理
        let currentActivityIndex = null;

        function openAddActivityModal() {
            currentActivityIndex = null;
            document.getElementById('activityName').value = '';
            document.getElementById('activityTime').value = '';
            document.getElementById('activityLocation').value = '';
            document.getElementById('addActivityModal').style.display = 'block';
        }

        function openEditActivityModal(index) {
            currentActivityIndex = index;
            let activities = JSON.parse(localStorage.getItem('activities')) || [];
            let activity = activities[index];
            document.getElementById('activityName').value = activity.name;
            document.getElementById('activityTime').value = activity.time;
            document.getElementById('activityLocation').value = activity.location;
            document.getElementById('addActivityModal').style.display = 'block';
        }

        function closeAddActivityModal() {
            document.getElementById('addActivityModal').style.display = 'none';
        }

        function saveActivity() {
            let activities = JSON.parse(localStorage.getItem('activities')) || [];
            let name = document.getElementById('activityName').value;
            let time = document.getElementById('activityTime').value;
            let location = document.getElementById('activityLocation').value;
            if (name && time && location) {
                if (currentActivityIndex!== null) {
                    activities[currentActivityIndex] = { name, time, location };
                } else {
                    activities.push({ name, time, location });
                }
                localStorage.setItem('activities', JSON.stringify(activities));
                initTables();
                closeAddActivityModal();
            }
        }

        function deleteActivity(index) {
            let activities = JSON.parse(localStorage.getItem('activities')) || [];
            activities.splice(index, 1);
            localStorage.setItem('activities', JSON.stringify(activities));
            initTables();
        }

        // 参与者管理
        let currentParticipantIndex = null;

        function openAddParticipantModal() {
            currentParticipantIndex = null;
            document.getElementById('participantName').value = '';
            document.getElementById('participantContact').value = '';
            document.getElementById('participantClass').value = '';
            document.getElementById('addParticipantModal').style.display = 'block';
        }

        function openEditParticipantModal(index) {
            currentParticipantIndex = index;
            let participants = JSON.parse(localStorage.getItem('participants')) || [];
            let participant = participants[index];
            document.getElementById('participantName').value = participant.name;
            document.getElementById('participantContact').value = participant.contact;
            document.getElementById('participantClass').value = participant.class;
            document.getElementById('addParticipantModal').style.display = 'block';
        }

        function closeAddParticipantModal() {
            document.getElementById('addParticipantModal').style.display = 'none';
        }

        function saveParticipant() {
            let participants = JSON.parse(localStorage.getItem('participants')) || [];
            let name = document.getElementById('participantName').value;
            let contact = document.getElementById('participantContact').value;
            let classInfo = document.getElementById('participantClass').value;
            if (name && contact && classInfo) {
                if (currentParticipantIndex!== null) {
                    participants[currentParticipantIndex] = { name, contact, class: classInfo };
                } else {
                    participants.push({ name, contact, class: classInfo });
                }
                localStorage.setItem('participants', JSON.stringify(participants));
                initTables();
                closeAddParticipantModal();
            }
        }

        function deleteParticipant(index) {
            let participants = JSON.parse(localStorage.getItem('participants')) || [];
            participants.splice(index, 1);
            localStorage.setItem('participants', JSON.stringify(participants));
            initTables();
        }

        // 报名信息管理
        let currentRegistrationIndex = null;

        function openAddRegistrationModal() {
            currentRegistrationIndex = null;
            document.getElementById('registrationActivity').value = '';
            document.getElementById('registrationParticipant').value = '';
            document.getElementById('registrationTime').value = '';
            document.getElementById('addRegistrationModal').style.display = 'block';
        }

        function openEditRegistrationModal(index) {
            currentRegistrationIndex = index;
            let registrations = JSON.parse(localStorage.getItem('registrations')) || [];
            let registration = registrations[index];
            document.getElementById('registrationActivity').value = registration.activity;
            document.getElementById('registrationParticipant').value = registration.participant;
            document.getElementById('registrationTime').value = registration.time;
            document.getElementById('addRegistrationModal').style.display = 'block';
        }

        function closeAddRegistrationModal() {
            document.getElementById('addRegistrationModal').style.display = 'none';
        }

        function saveRegistration() {
            let registrations = JSON.parse(localStorage.getItem('registrations')) || [];
            let activity = document.getElementById('registrationActivity').value;
            let participant = document.getElementById('registrationParticipant').value;
            let time = document.getElementById('registrationTime').value;
            if (activity && participant && time) {
                if (currentRegistrationIndex!== null) {
                    registrations[currentRegistrationIndex] = { activity, participant, time };
                } else {
                    registrations.push({ activity, participant, time });
                }
                localStorage.setItem('registrations', JSON.stringify(registrations));
                initTables();
                closeAddRegistrationModal();
            }
        }

        function deleteRegistration(index) {
            let registrations = JSON.parse(localStorage.getItem('registrations')) || [];
            registrations.splice(index, 1);
            localStorage.setItem('registrations', JSON.stringify(registrations));
            initTables();
        }

        // 活动评价管理
        let currentEvaluationIndex = null;

        function openAddEvaluationModal() {
            currentEvaluationIndex = null;
            document.getElementById('evaluationActivity').value = '';
            document.getElementById('evaluationPerson').value = '';
            document.getElementById('evaluationContent').value = '';
            document.getElementById('addEvaluationModal').style.display = 'block';
        }

        function openEditEvaluationModal(index) {
            currentEvaluationIndex = index;
            let evaluations = JSON.parse(localStorage.getItem('evaluations')) || [];
            let evaluation = evaluations[index];
            document.getElementById('evaluationActivity').value = evaluation.activity;
            document.getElementById('evaluationPerson').value = evaluation.person;
            document.getElementById('evaluationContent').value = evaluation.content;
            document.getElementById('addEvaluationModal').style.display = 'block';
        }

        function closeAddEvaluationModal() {
            document.getElementById('addEvaluationModal').style.display = 'none';
        }

        function saveEvaluation() {
            let evaluations = JSON.parse(localStorage.getItem('evaluations')) || [];
            let activity = document.getElementById('evaluationActivity').value;
            let person = document.getElementById('evaluationPerson').value;
            let content = document.getElementById('evaluationContent').value;
            let time = new Date().toLocaleString();
            if (activity && person && content) {
                if (currentEvaluationIndex!== null) {
                    evaluations[currentEvaluationIndex] = { activity, person, content, time };
                } else {
                    evaluations.push({ activity, person, content, time });
                }
                localStorage.setItem('evaluations', JSON.stringify(evaluations));
                initTables();
                closeAddEvaluationModal();
            }
        }

        function deleteEvaluation(index) {
            let evaluations = JSON.parse(localStorage.getItem('evaluations')) || [];
            evaluations.splice(index, 1);
            localStorage.setItem('evaluations', JSON.stringify(evaluations));
            initTables();
        }

        // 搜索活动
        function searchActivities() {
            let searchTerm = document.getElementById('activitySearch').value.toLowerCase();
            let activities = JSON.parse(localStorage.getItem('activities')) || [];
            let activityTable = document.getElementById('activityTable').getElementsByTagName('tbody')[0];
            activityTable.innerHTML = '';
            activities.forEach((activity, index) => {
                if (activity.name.toLowerCase().includes(searchTerm)) {
                    let row = activityTable.insertRow();
                    let cell1 = row.insertCell(0);
                    let cell2 = row.insertCell(1);
                    let cell3 = row.insertCell(2);
                    let cell4 = row.insertCell(3);
                    cell1.innerHTML = activity.name;
                    cell2.innerHTML = activity.time;
                    cell3.innerHTML = activity.location;
                    cell4.innerHTML = `<button class="edit-btn" onclick="openEditActivityModal(${index})">编辑</button><button class="delete-btn" onclick="deleteActivity(${index})">删除</button>`;
                }
            });
        }

        // 搜索参与者
        function searchParticipants() {
            let searchTerm = document.getElementById('participantSearch').value.toLowerCase();
            let participants = JSON.parse(localStorage.getItem('participants')) || [];
            let participantTable = document.getElementById('participantTable').getElementsByTagName('tbody')[0];
            participantTable.innerHTML = '';
            participants.forEach((participant, index) => {
                if (participant.name.toLowerCase().includes(searchTerm)) {
                    let row = participantTable.insertRow();
                    let cell1 = row.insertCell(0);
                    let cell2 = row.insertCell(1);
                    let cell3 = row.insertCell(2);
                    let cell4 = row.insertCell(3);
                    cell1.innerHTML = participant.name;
                    cell2.innerHTML = participant.contact;
                    cell3.innerHTML = participant.class;
                    cell4.innerHTML = `<button class="edit-btn" onclick="openEditParticipantModal(${index})">编辑</button><button class="delete-btn" onclick="deleteParticipant(${index})">删除</button>`;
                }
            });
        }

        // 搜索报名信息
        function searchRegistrations() {
            let searchTerm = document.getElementById('registrationSearch').value.toLowerCase();
            let registrations = JSON.parse(localStorage.getItem('registrations')) || [];
            let registrationTable = document.getElementById('registrationTable').getElementsByTagName('tbody')[0];
            registrationTable.innerHTML = '';
            registrations.forEach((registration, index) => {
                if (registration.activity.toLowerCase().includes(searchTerm) || registration.participant.toLowerCase().includes(searchTerm)) {
                    let row = registrationTable.insertRow();
                    let cell1 = row.insertCell(0);
                    let cell2 = row.insertCell(1);
                    let cell3 = row.insertCell(2);
                    let cell4 = row.insertCell(3);
                    cell1.innerHTML = registration.activity;
                    cell2.innerHTML = registration.participant;
                    cell3.innerHTML = registration.time;
                    cell4.innerHTML = `<button class="edit-btn" onclick="openEditRegistrationModal(${index})">编辑</button><button class="delete-btn" onclick="deleteRegistration(${index})">删除</button>`;
                }
            });
        }

        // 搜索活动评价
        function searchEvaluations() {
            let searchTerm = document.getElementById('evaluationSearch').value.toLowerCase();
            let evaluations = JSON.parse(localStorage.getItem('evaluations')) || [];
            let evaluationTable = document.getElementById('evaluationTable').getElementsByTagName('tbody')[0];
            evaluationTable.innerHTML = '';
            evaluations.forEach((evaluation, index) => {
                if (evaluation.activity.toLowerCase().includes(searchTerm) || evaluation.person.toLowerCase().includes(searchTerm)) {
                    let row = evaluationTable.insertRow();
                    let cell1 = row.insertCell(0);
                    let cell2 = row.insertCell(1);
                    let cell3 = row.insertCell(2);
                    let cell4 = row.insertCell(3);
                    let cell5 = row.insertCell(4);
                    cell1.innerHTML = evaluation.activity;
                    cell2.innerHTML = evaluation.person;
                    cell3.innerHTML = evaluation.content;
                    cell4.innerHTML = evaluation.time;
                    cell5.innerHTML = `<button class="edit-btn" onclick="openEditEvaluationModal(${index})">编辑</button><button class="delete-btn" onclick="deleteEvaluation(${index})">删除</button>`;
                }
            });
        }

        // 页面加载完成后初始化表格
        window.onload = function () {
            initTables();
        };
    </script>
</body>

</html>